﻿using System;
using System.Xml.Serialization;
using System.Collections.Generic;

namespace MetaMapics.Gpx
{
  public class Waypoint
  {
    [XmlAttribute("lon")] public double Longitude { get; set; }
    [XmlAttribute("lat")] public double Latitude { get; set; }

    [XmlElement("ele")] public double? Elevation { get; set; }
    [XmlIgnore] public bool ElevationSpecified { get { return Elevation.HasValue; } } 

    [XmlElement("time")] public DateTime? Time { get; set; }
    [XmlIgnore] public bool TimeSpecified { get { return Time.HasValue; } } 

    [XmlElement("magvar")] public double? MagneticVariation { get; set; }
    [XmlIgnore] public bool MagneticVariationSpecified { get { return MagneticVariation.HasValue; } } 

    [XmlElement("geoidheight")] public double? GeoidHeight { get; set; }
    [XmlIgnore] public bool GeoidHeightSpecified { get { return GeoidHeight.HasValue; } } 

    [XmlElement("name")] public string Name { get; set; }
    [XmlElement("cmt")] public string Comment { get; set; }
    [XmlElement("desc")] public string Description { get; set; }
    [XmlElement("src")] public string Source { get; set; }
    [XmlElement("link")] public List<Link> Links { get; set; }
    [XmlElement("sym")] public string Symbol { get; set; }
    [XmlElement("type")] public string Type { get; set; }

    [XmlElement("fix")] public Fix? Fix { get; set; }
    [XmlIgnore] public bool FixSpecified { get { return Fix.HasValue; } } 

    [XmlElement("sat")] public uint? Satellites { get; set; }
    [XmlIgnore] public bool SatellitesSpecified { get { return Satellites.HasValue; } } 

    [XmlElement("hdop")] public double? Hdop { get; set; }
    [XmlIgnore] public bool HdopSpecified { get { return Hdop.HasValue; } } 

    [XmlElement("vdop")] public double? Vdop { get; set; }
    [XmlIgnore] public bool VdopSpecified { get { return Vdop.HasValue; } } 

    [XmlElement("pdop")] public double? Pdop { get; set; }
    [XmlIgnore] public bool PdopSpecified { get { return Pdop.HasValue; } } 

    [XmlElement("ageofdgpsdata")] public double? AgeOfDGpsData { get; set; }
    [XmlIgnore] public bool AgeOfDGpsDataSpecified { get { return AgeOfDGpsData.HasValue; } } 

    [XmlElement("dgpsid")] public uint? DGpsId { get; set; }
    [XmlIgnore] public bool DGpsIdSpecified { get { return DGpsId.HasValue; } } 

    [XmlElement("extensions")] public Extensions Extensions { get; set; }

    public Waypoint()
    {
      Links = new List<Link>();
    }

    public Waypoint(double lon, double lat): this()
    {
      Longitude = lon;
      Latitude = lat;
    }
  }
}
